package com.foreknow.demo8;

public class Demo {

    public static void main(String[] args) {
        Pet[] p = new Pet[2];
        //给数组添加元素
        Dog p1 = new Dog();
        Penguin p2 = new Penguin();
        p[0] = p1;
        p[1] = p2;
        //从数组中获取元素
        Pet pet =  p[0]; //Dog
        Pet pet1 = p[1]; //Penguin
    }
}
